using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Runtime.InteropServices;

namespace VatGia
{
   
    public partial class FormSanPham : Form
    {
        
        private FormMain1 frm;
        DataService dservice = new DataService();
        DataTable dt = new DataTable();
        
        public FormSanPham(FormMain1 frm)
        {
            this.frm = frm;
            InitializeComponent();
          
        }

        private void btnXemChiTiet_Click(object sender, EventArgs e)
        {
            for (int i = dGV_DSSanPham.SelectedRows.Count - 1; i >= 0; i--)
            {
                if (dGV_DSSanPham.SelectedRows[i].Index <= dGV_DSSanPham.Rows.Count - 1)
                {
                    Public_variable.Masp = dGV_DSSanPham.SelectedRows[i].Cells[0].Value.ToString();
                }
            }
            frm.frm_ShowFormChiTiet();
           
        }
        public void LayDSSP()
        {
            dservice.Connect();
            SqlParameter[] parameters1 = new SqlParameter[1];
           // parameters1[0] = new SqlParameter("@username", Public_variable.Username);
            dt = dservice.ExcuteProcedureGetTable("sp_getSP", null, null);
            if (dt.Rows.Count > 0)
            {
                dGV_DSSanPham.DataSource = dt;
                dGV_DSSanPham.Columns[0].Visible = false;
                dGV_DSSanPham.Columns[1].Width = 200;
                dGV_DSSanPham.Columns[2].Width = 200;
                dGV_DSSanPham.Columns[3].Width = 170;
                dGV_DSSanPham.Columns[4].Width = 250;
            }
            dservice.Disconnect();
        }

        private void FormSanPham_Load(object sender, EventArgs e)
        {
            LayDSSP();
           
          
        }

      
    }
}
                                                                                                                                                                                                                                                                                                                                                                                